package com.filter;

import java.io.IOException;

import javax.servlet.*;
import javax.servlet.http.HttpServletRequest;
 
import com.model.User;

public class DefaultUserPagesFilter extends AbstractFilter implements Filter {
	

	public void destroy() {
		
	}
	

	public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
		HttpServletRequest req = (HttpServletRequest) request;
		User user = (User) req.getSession(true).getAttribute("user");

		if(!user.isUser() && !user.isAdmin()){
			accessDenied(request, response, req);
			return;
		}

		chain.doFilter(request, response);
	}


	public void init(FilterConfig arg0) throws ServletException {
		
	}
}
